Skip to content

Updated php.ini-production to reflect recommended defaults. bug 73726 #2238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4,939 commits into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Dec 12, 2016

suggesting changes as per https://bugs.php.net/bug.php?id=73726 to use more sane defaults[1] for the bundled php.ini-production config.

I guess some of those changes also need a code-change somewhere in a c-file?

As mentioned in the initial bug report, I guess we could even use bigger values for those defaults as "modern" servers provide way more memory.

[1] https://github.com/zendtech/ZendOptimizerPlus/blob/master/README#L44

TODOs

  • adjust php.ini-production
  • adjust php.ini-development
  • adjust zend_accelerator_module.c

derickr and others added 30 commits November 24, 2016 10:40
yet unfinished port to libmagic 5.28

catch with missing libmagic port pieces

regenerate data file with magic from 5.28

test magic files from 5.28

missing files

fix path

pure c99 is still not supported

move right to 5.29, yet some bugs present

more sync with orig lib

more ZMM usage

use unpatched data for now

partial revert according to bug #67705

Revert "more ZMM usage"

This reverts commit 5e3c9b8.

several fixes, so it's now closer to the clean port
Note the behavior change, FILEINFO_CONTINUE will now always
append a string \012-. I'm leaving this as is for now, as this is
the behavior change in libmagic.
* PHP-7.0:
  add test for bug #57547
* PHP-7.1:
  add test for bug #57547
* PHP-7.0:
  Fix int/size_t confusion in isValidPharFilename (bug #73580)
Now the conversions are explicit and do checks. Not sure it's
the best way but at least we can see them now in the open.
@krakjoe
Copy link
Member

krakjoe commented Jan 1, 2017

here is source code for INI

Would advise you leave revalidate_freq at the current default, as well as fast_shutdown (it is known that this can cause strangeness).

@staabm
Copy link
Contributor Author

staabm commented Jan 1, 2017

Thx, will do.

fast_shutdown (it is known that this can cause strangeness).

@krakjoe Could you elaborate, when/why this might lead to problems.. ? we should mention those situations in the .ini comments...

@weltling
Copy link
Contributor

weltling commented Jan 2, 2017

IMO default enablement should not be done. Not only because not all the scenarios do require it. It depends very much on a concrete system and goals. Fe, there might be collisions with other zend_extension's. While having more comments is good, the php.ini should be worky when just dropped in without reading any comments, which in experience often the use case :) So it'd be safer to leave such decisions up to a conscious user while keeping the entrance verge low for anyone.

Thanks.

@krakjoe
Copy link
Member

krakjoe commented Jan 3, 2017

OK, so I think it's best at this point to try to gather consensus on internals about this change, really we want dmitry to say this is okay, or this is not okay, and we want him to update the PECL extension to reflect whatever changes we decide are necessary.

@staabm
Copy link
Contributor Author

staabm commented Jan 3, 2017

I am also fine to disable opcache by default, but at least the buffer sizes/memory settings should reflect the recommendations.

symfony for example suggests opcache.max_accelerated_files of 20.000
http://symfony.com/doc/current/performance.html#optimizing-all-the-files-used-by-symfony
maybe the default for php should be even bigger as the one I suggested with this PR. can a value of e.g. 10.000 hurt on a modern server in some cases?

see also https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
and https://tideways.io/profiler/blog/fine-tune-your-opcache-configuration-to-avoid-caching-suprises

thx for your feedback.

@staabm
Copy link
Contributor Author

staabm commented Jan 4, 2017

I did some testing on ubuntu14lts with php7.0.14

test with http://symfony.com/blog/introducing-the-symfony-demo-application (using symfony 3.2.1) requires...
opcache.max_accelerated_files =~6900

var_dump(opcache_get_status());

array(8) {
  ["opcache_enabled"]=>
  bool(true)
  ["cache_full"]=>
  bool(false)
  ["restart_pending"]=>
  bool(false)
  ["restart_in_progress"]=>
  bool(false)
  ["memory_usage"]=>
  array(4) {
    ["used_memory"]=>
    int(109038624)
    ["free_memory"]=>
    int(561972152)
    ["wasted_memory"]=>
    int(77864)
    ["current_wasted_percentage"]=>
    float(0.011602640151978)
  }
  ["interned_strings_usage"]=>
  array(4) {
    ["buffer_size"]=>
    int(41943040)
    ["used_memory"]=>
    int(3464320)
    ["free_memory"]=>
    int(38478720)
    ["number_of_strings"]=>
    int(42828)
  }
  ["opcache_statistics"]=>
  array(13) {
    ["num_cached_scripts"]=>
    int(988)
    ["num_cached_keys"]=>
    int(1837)
    ["max_cached_keys"]=>
    int(262237)
    ["hits"]=>
    int(34702)
    ["start_time"]=>
    int(1483555301)
    ["last_restart_time"]=>
    int(0)
    ["oom_restarts"]=>
    int(0)
    ["hash_restarts"]=>
    int(0)
    ["manual_restarts"]=>
    int(0)
    ["misses"]=>
    int(999)
    ["blacklist_misses"]=>
    int(0)
    ["blacklist_miss_ratio"]=>
    float(0)
    ["opcache_hit_rate"]=>
    float(97.201759054368)
  }
...

test with https://github.com/bestmomo/laravel5-3-example (using laravel 5.3) requires...
opcache.max_accelerated_files =~5400

var_dump(opcache_get_status());

array(8) {
  ["opcache_enabled"]=>
  bool(true)
  ["cache_full"]=>
  bool(false)
  ["restart_pending"]=>
  bool(false)
  ["restart_in_progress"]=>
  bool(false)
  ["memory_usage"]=>
  array(4) {
    ["used_memory"]=>
    int(99237208)
    ["free_memory"]=>
    int(571849824)
    ["wasted_memory"]=>
    int(1608)
    ["current_wasted_percentage"]=>
    float(0.00023961067199707)
  }
  ["interned_strings_usage"]=>
  array(4) {
    ["buffer_size"]=>
    int(41943040)
    ["used_memory"]=>
    int(1480712)
    ["free_memory"]=>
    int(40462328)
    ["number_of_strings"]=>
    int(22911)
  }
  ["opcache_statistics"]=>
  array(13) {
    ["num_cached_scripts"]=>
    int(330)
    ["num_cached_keys"]=>
    int(617)
    ["max_cached_keys"]=>
    int(262237)
    ["hits"]=>
    int(2351)
    ["start_time"]=>
    int(1483554683)
    ["last_restart_time"]=>
    int(0)
    ["oom_restarts"]=>
    int(0)
    ["hash_restarts"]=>
    int(0)
    ["manual_restarts"]=>
    int(0)
    ["misses"]=>
    int(331)
    ["blacklist_misses"]=>
    int(0)
    ["blacklist_miss_ratio"]=>
    float(0)
    ["opcache_hit_rate"]=>
    float(87.65846383296)
  }
...

values determined as described in
https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html
with php builtin server running in cli with cli-opcache enabled.


I guess the interessting numbers are ["interned_strings_usage"]["used_memory"] and ["memory_usage"]["used_memory"], right?

demo-app interned-strings-buffer opcache-mem max_accelerated_files
symfony 3.2.1 demo 3.464.320b 109.038.624b 6900
laravel5.3 demo 1.480.712b 99.237.208b 5400

current default for interned-strings-buffer is 4MB (nearly ~90% consumed in symfony demo)
current default for opcache-mem is 64 (I guess MB?) (demos require ~1,5x more)
current default for max_accelerated_files is 2000 (~3-3,5x more required)

hope those numbers are enough, or do we need more?

My proposal for the new defaults are
8MB interned-strings-buffer
128MB opcache-mem
10.000 max_accelerated_files

@krakjoe
Copy link
Member

krakjoe commented Jan 4, 2017

They look like reasonable suggestions to me, thanks for the effort.

@dstogov we need your input here, please review.

If we get no response, I'll just merge it in a few days and assume dmitry is okay with it, although ideally pecl should mirror these changes and I have no permission to update that.

TODO: Update programmatic defaults
@dstogov
Copy link
Member

dstogov commented Jan 9, 2017

Increasing opcache.max_accelerated_files, opcache.interned_strings_buffer and opcache.memory_consumption makes sense.

opcache.enable_cli=1 didn't make practical benefits before PHP-7.1, but since PHP-7.1, new optimizer significantly improves speed of some CLI applications. So, this may make sense.

opcache.fast_shutdown may cause some incompatibilities.

@krakjoe
Copy link
Member

krakjoe commented Jan 9, 2017

@dstogov thanks for input, glad to see you back from holidays :)

@staabm we can now move forward ...

Please update defaults (in code and ini) to reflect changes suggested by dmitry for 7.0 on this PR.
Please create a PR based on 7.1 to enable_cli in code and ini.
Please update development ini in both (same values as production).

@php-pulls
Copy link

php-pulls commented Jan 9, 2017 via email

@kelunik
Copy link
Member

kelunik commented Jan 9, 2017

But for the file cache we need a configured directory, no?

@krakjoe
Copy link
Member

krakjoe commented Jan 9, 2017

@staabm it does, but filling up tmp with files is not a good idea ... so we can't enable file cache by default whatever.

@staabm
Copy link
Contributor Author

staabm commented Jan 9, 2017

@krakjoe I deleted my initial comment a few mins after posting it, as I realized it does not have a php-ini default

see https://php-lxr.adamharvey.name/source/xref/master/ext/opcache/zend_accelerator_module.c#318

@dstogov
Copy link
Member

dstogov commented Jan 9, 2017

I wouldn't recommend enabling file cache by default.

@krakjoe
Copy link
Member

krakjoe commented Jan 9, 2017

@dstogov ACK, we don't plan too :)

@weltling
Copy link
Contributor

weltling commented Jan 9, 2017

As a note, about Opcache and CLI, came across this kind of bug yesterday, again https://bugs.php.net/bug.php?id=73879 . Well, seems it happens no matter it's in default ini, or not :)

Thanks.

@staabm staabm changed the base branch from master to PHP-7.0 January 9, 2017 10:25
@staabm
Copy link
Contributor Author

staabm commented Jan 9, 2017

something went wrong while changing the merge base... will create a separate PR with the changes required.

@krakjoe
Copy link
Member

krakjoe commented Jan 9, 2017

@staabm ack, closing ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.